package com.qiall.game.gobang.command;

import com.qiall.common.exception.BusinessException;
import com.qiall.common.exception.ResultCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

@Component
public class GetCommandService {

    @Autowired
    @Qualifier("connectCommandService")
    private CommandService connectCommondService;
    @Autowired
    @Qualifier("sendMoveCommandService")
    private CommandService sendMoveCommandService;

    public CommandService getService(String command) {
        if (command.equals(CommandEnum.CONNECT.getCode())) {
            return connectCommondService;
        }
        if (command.equals(CommandEnum.MOVE.getCode())) {
            return sendMoveCommandService;
        }
        throw new BusinessException(ResultCode.SYSTEM_ERROR,"not support command:"+command);
    }
}
